package com.sh.data.engine.application.model.dto.api;

import com.sh.data.engine.domain.api.model.domain.DataApiRegisterDomain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * @author : fuchen
 * @date : 2022/1/24 18:10
 */
@Data
@Schema
public class DataApiResponse {

    @Schema(description = "请求方式")
    private String apiMethod;

    @Schema(description = "id")
    private Long id;

    @Schema(description = "0-向导模式 1-脚本模式 2-注册模式")
    private Integer apiType;

    @Schema(description = "api名称")
    private String apiName;

    @Schema(description = "api传输协议")
    private String apiProtocol;

    @Schema(description = "api路径")
    private String apiPath;

    @Schema(description = "api groupId")
    private Long apiGroupId;

    @Schema(description = "api 描述")
    private String apiDesc;

    @Schema(description = "数据源id")
    private Long datasourceId;

    @Schema(description = "表名称")
    private String tableName;

    @Schema(description = "数据源名称")
    private String datasourceName;

    @Schema(description = "dirId")
    private Long dirId;

    @Schema(description = "indexId")
    private Long indexId;

    @Schema(description = "出参 参数列表,脚本模式、向导模式需要")
    private List<DataApiParamResponse> outputParamResponses;

    @Schema(description = "入参 参数列表,脚本模式、向导模式需要")
    private List<DataApiParamResponse> inputParamResponses;

    @Schema(description = "脚本")
    private String apiScript;

    @Schema(description = "是否开启分页 0- 不开启 1开启")
    private Integer pageable;

    @Schema(description = "返回事例")
    private String responseExample;

    @Schema(description = "0-apiToken  1- userToken")
    private Integer authType;

    @Schema(description = "注册模式需要")
    private DataApiRegisterDomain dataApiRegisterDomain;

    @Schema(description = "测试API url")
    private String testApiUrl;

    @Schema(description = "生产 url")
    private String prodApiUrl;

    @Schema(description = "api分组")
    private String apiGroup;

    @Schema(description = "指标分组")
    private String indexGroup;

    @Schema(description = "指标名称")
    private String indexName;

    @Schema(description = "1 : 加密 ")
    private Integer isSecurity;

    @Schema
    @Data
    public static class DataApiParamResponse {

        @Schema(description = "参数类型0 - 输入参数 1-输出参数")
        private Integer paramType;

        @Schema(description = "参数名称")
        private String paramName;

        @Schema(description = "参数位置 query head body")
        private String paramPosition;

        @Schema(description = "绑定字段名")
        private String bindColumnName;

        @Schema(description = "参数数据类型")
        private String paramDataType;

        @Schema(description = "操作符0 -等于 1-like 2-in")
        private Integer paramOperator;

        @Schema(description = "是否必填 0-非必填 1-必填")
        private Integer paramRequire;

        @Schema(description = "示例值")
        private String exampleValue;

        @Schema(description = "默认值")
        private String defaultValue;

        @Schema(description = "描述")
        private String paramDesc;

        private String orderBy;
    }
}
